public class Laud{
	private int[][] Laud = new int[3][3];
	
	public Laud(){
		puhastaLaud();
	}
	
	public void puhastaLaud(){
		for(int rida=0; rida<3; rida++)
			for(int veerg=0; veerg<3; veerg++)
				Laud[rida][veerg]=0;
	}
	public void naitaLaud(){
		System.out.println();
		for(int rida=0; rida<3; rida++){
			for(int veerg=0; veerg<3; veerg++){
				if(Laud[rida][veerg]==-1){
					System.out.print(" X ");
				}
				if(Laud[rida][veerg]==1){
					System.out.print(" O ");
				}
				if(Laud[rida][veerg]==0){
					System.out.print("   ");
				}
				if(veerg==0 || veerg==1)
					System.out.print(" | ");
			}
			System.out.println();
		}
	}
	
	 public int getPosition(int[] proov){
        return Laud[proov[0]][proov[1]];
    }
    
    public void setPosition(int[] proov, int m2ngija){
        if(m2ngija == 1)
            Laud[proov[0]][proov[1]] = -1;
        else
            Laud[proov[0]][proov[1]] = 1;
    }

    public int vaataRida(){
        for(int rida=0 ; rida<3 ; rida++){

            if( (Laud[rida][0] + Laud[rida][1] + Laud[rida][2]) == -3)
                return -1;
            if( (Laud[rida][0] + Laud[rida][1] + Laud[rida][2]) == 3)
                return 1;
        }
        
        return 0;
                
    }
    
    public int vaataVeerg(){
        for(int veerg=0 ; veerg<3 ; veerg++){

            if( (Laud[0][veerg] + Laud[1][veerg] + Laud[2][veerg]) == -3)
                return -1;
            if( (Laud[0][veerg] + Laud[1][veerg] + Laud[2][veerg]) == 3)
                return 1;
        }
        
        return 0;
                
    }
    
    public int vaataDiagonaal(){
        if( (Laud[0][0] + Laud[1][1] + Laud[2][2]) == -3)
            return -1;
        if( (Laud[0][0] + Laud[1][1] + Laud[2][2]) == 3)
            return 1;
        if( (Laud[0][2] + Laud[1][1] + Laud[2][0]) == -3)
            return -1;
        if( (Laud[0][2] + Laud[1][1] + Laud[2][0]) == 3)
            return 1;
        
        return 0;
    }

    public boolean t2isLaud(){
        for(int rida=0 ; rida<3 ; rida++)
            for(int veerg=0 ; veerg<3 ; veerg++)
                if( Laud[rida][veerg]==0 )
                    return false;
        return true;
    }
}